<!-- include tpl=cart/header title=结算信息 -->
<section class="container pt-4">
	<input type="hidden" name="is_virtual" id="is_virtual" value="{$is_virtual ? 1 : 0}" />
	<!-- if !$session.user_id -->
	<div class="card mb-3">
		<div class="card-header">
			友情提示：我们强烈建议成为我们的用户再下单
		</div>
		<div class="card-body">
			<div class="p-4 m-4 text-center">
				<input type="button" value="您还未登录，请先登录" onclick="$.login.open()" class="btn btn-secondary" />
				<a href="{url ctrl=register/}" target="_blank" class="btn btn-primary">还没有注册，请先注册</a>
			</div>
		</div>
	</div>
	<!-- /if -->
	<form method="post" id="saveorder" onsubmit="return check_it()" class="am-form am-form-horizontal">
	<!-- if $is_virtual -->
	<div class="card">
		<div class="card-header">
			收件人信息
		</div>
		<div class="card-body">
			<div class="form-group">
				<label for="email">Email</label>
				<input type="email" class="form-control" id="email" name="email" placeholder="输入你的电子邮件" value="{$address.email}"/>
			</div>
			<div class="form-group">
				<label for="mobile">手机号</label>
				<input type="tel" class="form-control" id="mobile" name="mobile" placeholder="填写手机号" value="{$address.mobile}"/>
			</div>
		</div>
	</div>
	<!-- else -->
		<!-- include tpl=cart/checkout-address -->
	<!-- /if -->
	<div class="card mt-3">
		<div class="card-header">
			产品信息
		</div>
		<table class="table">
			<thead>
				<tr>
					<th>图片</th>
					<th>名称</th>
					<th width="80px">数量</th>
					<th width="150px">售价</th>
				</tr>
			</thead>
			<tbody>
				<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
				<tr>
					<td><input type="hidden" name="id[]" data-name="product" value="{$value.id}" /><img src="{$value.thumb ? $value.thumb : 'images/nopic.png'}" width="80px" border="0" alt="{$value.title}" /></td>
					<td>
						<div><b>{$value.title}</b></div>
						<!-- loop from=$value._attrlist key=$k value=$v id=$tmpid -->
						<div>{$v.title}：{$v.content}</div>
						<!-- /loop -->
						<div>单价：{func price_format $value.price $value.currency_id}</div>
					</td>
					<td>{$value.qty}</td>
					<td>
						<!-- if $value.discount -->
						<div class="text-muted"><del>{func price_format $value.price*$value.qty $value.currency_id}</del></div>
						<!-- /if -->
						<div class="text-danger">{func price_format $value.price_total $value.currency_id}</div>
						<!-- loop from=$value.appslist key=$k value=$v id=$idxx -->
						<div class="text-muted"><small>{$v.title}</small></div>
						<!-- /loop -->
					</td>
				</tr>
				<!-- /loop -->
			</tbody>
		</table>
	</div>
	<div class="card mt-3">
		<div class="card-header">
			优惠码
		</div>
		<div class="card-body">
			<div class="row">
				<div class="col-sm-3"><input type="text" name="coupon" class="form-control" id="coupon" value="{$coupon_code}" /></div>
				<div class="col-sm-1"><input type="button" value="提交优惠码" onclick="update_coupon()" class="btn btn-primary" /></div>
				<div class="col-sm-8" id="coupon_tips"></div>
			</div>
		</div>
	</div>
	<div class="card mt-3">
		<div class="card-header">
			留言，填写您对购买的商品特别要求，不能超过80字
		</div>
		<div class="card-body">
			
			<textarea name="note" id="note" class="form-control" style="resize:none;"></textarea>
		</div>
	</div>
	<div class="card mt-3" id="price_info_panel">
		<div class="card-header">
			信息汇总
		</div>
		<div class="card-body p-0" id="price_info">
			<table class="table">
				<!-- loop from=$pricelist key=$key value=$value id=$tmpid -->
				<tr>
					<td class="text-end">
						<input type="hidden" name="ext_price[{$value.identifier}]" id="ext_price_{$value.identifier}" value="" />
						{$value.title}：</td>
					<td id="{$value.identifier}_price" class="text-danger">{$value.price}</td>
				</tr>
				<!-- /loop -->
				<tr>
					<td class="text-end">总价：</td>
					<td id="all_price" class="text-danger" width="150px">{$price}</td>
				</tr>
			</table>
		</div>
	</div>
	<!-- if $integral -->
	<div class="card mt-3">
		<div class="card-header">积分抵扣，仅支持100的整数倍，不支持小数</div>
		<ul class="list-group list-group-flush">
			<!-- loop from=$integral key=$key value=$value -->
		    <li class="list-group-item">
			    <div class="row">
				    <div class="col-sm-8">您当前的<span class="am-text-danger">{$value.title}</span>有 <span class="am-text-danger">{$value.val}</span>{$value.unit}，最多可抵现金<span class="red">{func price_format $value.price}</span></div>
				    <div class="col-sm-4">
					    <table>
					    	<tr>
					    		<td style="width:60px;text-align:right;">支出：</td>
					    		<td><input type="text" name="integral_val[{$key}]" class="form-control" data-name="integral" data-key="{$key}" /></td>
					    		<td>&nbsp;{$value.unit}</td>
					    	</tr>
					    </table>
				    </div>
			    </div>
		    </li>
		    <!-- /loop -->
		</ul>
	</div>
	<!-- /if -->
	<!-- if $balance -->
	<div class="card mt-3">
		<div class="card-header">余额支付</div>
		<div class="card-body">
			<!-- loop from=$balance key=$key value=$value -->
			<div class="form-check">
				<label class="form-check-label mb-2">
			    	<input type="radio" class="form-check-input" name="payment" value="{$value.identifier}" data-price="{$price_val}" data-balance="{$value.price}" />
			    	您当前的{$value.title}有<span class="red">{$value.val}</span>{$value.unit}
			    	<!-- if $price_val > $value.price -->
					，您的{$value.title}不够，请 <a href="{url ctrl=payment id=$value.id/}" target="_blank"><b>在线充值</b></a>
					<!-- /if -->
				</label>
			</div>
			<!-- /loop -->
		</div>
	</div>
	<!-- /if -->
	<!-- loop from=$paylist key=$key value=$value id=$tmpid -->
	<div class="card mt-3">
		<div class="card-header">{$value.title}</div>
		<div class="card-body">
			<!-- loop from=$value.paylist key=$k value=$v id=$idxx -->
			<div class="form-check">
				<label class="form-check-label mb-2">
			    	<input type="radio" class="form-check-input" name="payment" value="{$v.id}"{if !$tmpid.index && !$idxx.index} checked{/if} />
			    	<!-- if $v.logo1 -->
			    	<img src="{$v.logo1}" style="width:40px;"  />
			    	<!-- /if -->
			    	{$v.title}
				</label>
			</div>
			<!-- /loop -->
		</div>
	</div>
	<!-- /loop -->
	<div class="card mt-3">
		<div class="card-header">仅下单</div>
		<div class="card-body">
			<div class="form-check">
				<label class="form-check-label mb-2">
			    	<input type="radio" class="form-check-input" name="payment" value="0" checked />
			    	仅下单
				</label>
			</div>
		</div>
	</div>
	<div class="m-3 text-center">
		<input type="submit" value="提交订单" class="btn btn-primary btn-lg" />
	</div>
	</form>
</section>
<!-- include tpl=cart/footer -->